﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace net.xBei.WebApi.Filters {
    internal class ExceptionFilterAttribute : Microsoft.AspNetCore.Mvc.Filters.ExceptionFilterAttribute {
        public override void OnException(ExceptionContext context) {
            //base.OnException(context);
            context.Result = new OkObjectResult(new {
                success = false,
                code = 500,
#if DEBUG
                message = context.Exception.Message,
                context.Exception.StackTrace,
#else
                message = "服务异常",
#endif
            }) {
                StatusCode = 500
            };
        }
    }
}
